package net.weitalk.newfeatures;

/**
 * Records is released in JDK16.
 */

record Circle(double radius) {
    
    public Circle {
        if (radius < 0) {
            throw new IllegalArgumentException(
                    "The radius cannot be negative [" + radius + "]"
            );
        }
    }
    
    public double area() {
        return Math.PI * radius * radius;
    }
}

public class RecordUseCases {
    public static void main(String[] args) {
        Circle c1 = new Circle(10.0);
        Circle c2 = new Circle(10.0);
        System.out.println(c1.equals(c2));
        System.out.println(c1 == c2);
    }
}
